<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width,initial-scale=1,maximum-scale=1,minimum-scale=1,user-scalable=no">
    <title>后台管理系统</title>
    <meta name="referrer" content="no-referrer">
    <link rel="stylesheet" href="https://at.alicdn.com/t/c/font_4755950_cmhps6g8f.css">
    <link rel="stylesheet" href="../style/common.css">
</head>

<body>
    <header class="bg-base flex aic pl-20">
        <h3 class="fff">果莱人才网后台管理系统</h3>
    </header>

    <main class="bg-fff" style="margin-left: 0;">
        <div class="pl-30 mb-20 flex jc-sb pr-30">
            <span>添加职位</span>
            <!-- <span class="base cursor">添加</span> -->
        </div>
        <div class="ml-30 form">
            <p class="item mt-10">
                <span>工作名称 </span>
                <input id="workTitle" type="text" class="ml-10" placeholder="请输入" >
            </p>
            <p class="item mt-10">
                <span>薪资</span>
                <input id="price" type="text" class="ml-10" placeholder="请输入" >
            </p>
            <p class="item mt-10">
                <span>发布时间</span>
                <input id="time" type="text" class="ml-10" placeholder="请输入" >
            </p>
            <p class="item mt-10">
                <span>工作地址</span>
                <input id="conditionAddress" type="text" class="ml-10" placeholder="请输入" >
            </p>
            <p class="item mt-10">
                <span>工作经验</span>
                <input id="conditionExperience" type="text" class="ml-10" placeholder="请输入" >
            </p>
            <p class="item mt-10">
                <span>学历要求</span>
                <input id="conditionEdu" type="text" class="ml-10" placeholder="请输入" >
            </p>
            <p class="item mt-10">
                <span>公司</span>
                <input id="companyName" type="text" class="ml-10" placeholder="请输入" >
            </p>
            <p class="item mt-10">
                <span>工作要求</span>
                <input id="jobDetails" type="text" class="ml-10" placeholder="请输入" >
            </p>
            <p class="item mt-10">
                <span>公司logo</span>
                <input id="imgUrl" type="text" class="ml-10" placeholder="请输入图片地址"
                    value="">
            </p>

            <p class="item mt-30 ml-30 pl-25">
                <button id="submit" class="btn submit ml-30">提交</button>
            </p>
        </div>

    </main>


    <script src="../js/jquery.js"></script>
    <script src="../js/axios.js"></script>
    <script src="../js/common.js"></script>
    <script>
        var addObj = {
            bindEvents() {
                $('#submit').on('click', function () {
                    addObj.add();
                })
            },
            // 添加数据
            add() { 
                var url = 'http://localhost:3000/browsing';
                var data = {
                    imgUrl: $('#imgUrl').val(),
                    workTitle: $('#workTitle').val(),
                    price: $('#price').val(), 
                    companyName: $('#companyName').val(), 
                    jobDetails: $('#jobDetails').val(),  
                    conditionAddress: $('#conditionAddress').val(),  
                    conditionExperience: $('#conditionExperience').val(),  
                    conditionEdu: $('#conditionEdu').val(),  
                    time: $('#time').val(),  
                }
                axios.post(url, data).then(function (res) {
                    // 添加成功后跳转回列表页面
                    location.href = './list.html';
                }).catch(function(err) {
                    console.log('错误',err); 
                })

                // {
                //     "description": "小仙女们最爱的泳池酒店",
                //     "hashid": "e9qGD4mGWo",
                //     "id": 715,
                //     "imageUrl": "https://img2.baidu.com/it/u=1337068678,3064275007&fm=253&fmt=auto&app=120&f=JPEG?w=500&h=750",
                //     "kind": "01",
                //     "title": "找到了！国内最受欢迎的网红泳池酒店，我带上你，你带上钱，出发吧！",
                //     "url": "#/topic/detail/e9qGD4mGWo?timeStamp=1649300416705",
                //     "kindName": "推荐•路线"
                // } 
            }
        }
        addObj.bindEvents();
    </script>

</body>

</html>